﻿using Learn.Infraestrutura.EFCore;
using Learn.Infraestrutura.Tools;
using Learn.Service.Interface;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Linq;

namespace Learning.Api.Admin.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BaseController : ControllerBase
    {
        protected readonly I_Login_Service _login_Service;

        public BaseController(I_Login_Service login_Service)
        {
            //System.Threading.Thread.Sleep(1500);
            _login_Service = login_Service;

        }
        /// <summary>
        /// 获取当前登录用户
        /// </summary>
        /// <returns></returns>
        protected SysUsers Get_Curr_User()
        {
            string code = this.User.Claims.ToList().First(o => o.Type == System.Security.Claims.ClaimTypes.Name).Value;
            var user = _login_Service.Get_User_By_LastCode(code, Config.GetIp());
            return user;
        }


    }
}
